package com.example.john.ksoap2android;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }


    public void getPro(View view) {
        new Thread(){
            @Override
            public void run() {
                try{
                    String url="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
                    String ns="http://WebXml.com.cn/";
                    String action="getRegionProvince";
                    HttpTransportSE trans=new HttpTransportSE(url);
                    SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    SoapObject body=new SoapObject(ns, action);
                    envelope.setOutputSoapObject(body);
                    trans.call(ns+action, envelope);
                    System.out.println(envelope.bodyIn.getClass().getName());
                    SoapObject rs=(SoapObject)envelope.bodyIn;
                    SoapObject rs1=(SoapObject)rs.getProperty(0);
                    int m=rs1.getPropertyCount();

                    for(int i=0;i<m;i++){
                        Log.i("john",rs1.getProperty(i).toString());
                    }
                }
                catch (Exception e){
                    Log.i("john",e.getMessage());
                }
            }
        }.start();

    }
}
